import 'package:flutter/material.dart';
import 'package:flutter_app/config/widgetconfig.dart';
import 'package:flutter_app/config/colorconfig.dart';
import 'package:flutter_app/tabs/tabs.dart';

class FansPage extends StatefulWidget {
  FansPage({Key key}) : super(key: key);

  @override
  _FansPageState createState() => _FansPageState();
}

class _FansPageState extends State<FansPage>
    with SingleTickerProviderStateMixin {
  //一定要with single.....这玩意
  TabController _tabController;
  void initState() {
    super.initState();
    _tabController = TabController(length: 4, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        iconTheme: IconThemeData(
          color: Colors.grey,
        ),
        centerTitle: true,
        title: Text(
          "粉丝",
          style: TextStyle(color: darkgreen),
        ),
        backgroundColor: Colors.white,
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          PreferredSize(
              preferredSize: Size(50, 500),
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.fromLTRB(15, 10, 15, 5),
                    child: FlatButton(
                      onPressed: () {},
                      shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.all(Radius.circular(20))),
                      color: defaultyellow,
                      child: Container(
                        width: double.infinity,
                        height: 30,
                        alignment: Alignment.center,
                        child: Text("搜索全部粉丝"),
                      ),
                    ),
                  ),
                  TabBar(
                    controller: _tabController,
                    indicatorColor: darkgreen,
                    tabs: <Widget>[
                      Tab(
                        child: Column(
                          children: <Widget>[
                            Icon(
                              Icons.transform,
                              size: 25,
                              color: darkgreen,
                            ),
                            Text(
                              "互相关注",
                              style: TextStyle(color: darkgreen),
                            )
                          ],
                        ),
                      ),
                      Tab(
                        child: Column(
                          children: <Widget>[
                            Icon(
                              Icons.people,
                              color: darkgreen,
                            ),
                            Text(
                              "我的分组",
                              style: TextStyle(color: darkgreen),
                            )
                          ],
                        ),
                      ),
                      Tab(
                        child: Column(
                          children: <Widget>[
                            Icon(
                              Icons.warning,
                              color: darkgreen,
                            ),
                            Text(
                              "黑名单",
                              style: TextStyle(color: darkgreen),
                            )
                          ],
                        ),
                      ),
                      Tab(
                        child: Column(
                          children: <Widget>[
                            Icon(
                              Icons.add_comment,
                              color: darkgreen,
                            ),
                            Text(
                              "推荐好友",
                              style: TextStyle(color: darkgreen),
                            )
                          ],
                        ),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 10,
                    child: Container(color: defaultgreen),
                  )
                ],
              )),
          Expanded(
              child: TabBarView(controller: _tabController, children: fansList))
        ],
      ),
    );
  }
}

class UserSynopsisInFans extends StatefulWidget {
  UserSynopsisInFans({Key key}) : super(key: key);

  @override
  _UserSynopsisInFansState createState() => _UserSynopsisInFansState();
}

class _UserSynopsisInFansState extends State<UserSynopsisInFans> {
  @override
  Widget build(BuildContext context) {
    return UserSynopsis(
        trall: FlatButton(
      onPressed: () {},
      child: Text("+关注"),
      shape: StadiumBorder(),
      splashColor: Colors.green,
      focusColor: Colors.red,
    ));
  }
}

List<Widget> fansList = [
  SingleChildScrollView(
    child: ExpansionTile(
      title: Text("我的全部分组"),
      initiallyExpanded: true,
      children: <Widget>[
        ExpansionTile(
            title: Text(
          "分组名称1",
          textScaleFactor: 0.8,
        )),
        ExpansionTile(
            title: Text(
          "分组名称2",
          textScaleFactor: 0.8,
        )),
        ExpansionTile(
          title: Text(
            "分组名称3",
            textScaleFactor: 0.8,
          ),
          children: <Widget>[
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
            UserSynopsisInFans(),
          ],
        ),
      ],
    ),
  ),
  Container(
    decoration: BoxDecoration(color: Colors.green),
  ),
  Container(
    decoration: BoxDecoration(color: Colors.red),
  ),
  Container(
    decoration: BoxDecoration(color: Colors.yellow),
  ),
];
